package com.telit.firecommand.controller;

import com.telit.common.entity.DataReturn;
import com.telit.firecommand.entity.CommFireLoss;
import com.telit.firecommand.service.CommFireLossService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
  Create by Chencf 2023/01/18
 */
@RestController
@RequestMapping("/fire-loss")
@Api(tags = "火灾损失接口",description = "/fire-loss")
public class CommFireLossController {

    @Autowired
    private CommFireLossService commFireLossService;


    @PostMapping("/add")
    @ApiOperation("新增或修改灾损统计数据")
    public DataReturn add(@RequestBody CommFireLoss commFireLoss){
        commFireLossService.add(commFireLoss);
        return DataReturn.ok();
    }

    @GetMapping("/queryByFireId")
    @ApiOperation("根据火情id查询灾损数据")
    public DataReturn<CommFireLoss> queryByFireId(@RequestParam Long fireId) {
        CommFireLoss commFireLoss = commFireLossService.queryByFireId(fireId);
        return DataReturn.ok(commFireLoss);
    }

}
